import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { AtTabs, AtTabsPane } from 'taro-ui'

import videoApi from '@api/video'

import './index.scss'

class MyVideo extends Component {
  constructor (props) {
    super(props)
    this.state = {
      current: 0,
      tabList: []
    }
  }

  config = {
    navigationBarTitleText: '视频'
  }

  componentWillMount () { }

  componentDidMount () {
    videoApi.videoTabs().then(res => {
      res.data.forEach(item => {
        item.title = item.name
      })
      this.setState({
        tabList: res.data
      })
    })
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }
  
  handleClick (value) {
    this.setState({
      current: value
    })
  }

  render () {
    return (
      <View className='index'>
        <AtTabs current={this.state.current} scroll tabList={this.state.tabList} onClick={this.handleClick.bind(this)}>
          <AtTabsPane current={this.state.current} index={0} >
            
          </AtTabsPane>
          <AtTabsPane current={this.state.current} index={1}>
            
          </AtTabsPane>
        </AtTabs>
      </View>
    )
  }
}

export default MyVideo
